package com.yeyks.other.dal.dao;

import com.yeyks.other.dal.domain.CouponInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;


/**
 * <p>
 * 券表 Mapper 接口
 * </p>
 *
 * @author yun
 * @since 2019-06-25
 */
public interface CouponInfoMapper extends BaseMapper<CouponInfo> {

    int insertReturnId(CouponInfo record);

    List<CouponInfo> selectByStatus(@Param("statusList") List<Integer> statusList);

    List<CouponInfo> selectAvailable(@Param("hotelId") String hotelId, @Param("roomId") String roomId);

    int updateStatusByPrimaryKey(CouponInfo record);

    List<CouponInfo> selectByFilter(@Param("type") Integer type, @Param("status") Integer status, @Param("keyword") String keyword,
                                    @Param("dateBegin") String dateBegin, @Param("dateEnd") String dateEnd,
                                    @Param("offset") Integer offset, @Param("maxrow") Integer maxrow);

    int countByFilter(@Param("type") Integer type, @Param("status") Integer status, @Param("keyword") String keyword,
                      @Param("dateBegin") String dateBegin, @Param("dateEnd") String dateEnd);

    int updateValidEndNow(@Param("id") Integer id);

    List<Map> selectByUser(@Param("id") Integer id, @Param("used") Boolean used, @Param("valid") Boolean valid, @Param("couponId") Integer couponId);

    List<Map<String, Object>> statCouponUsed();

    /**
     * 通过付款金额查询对应的有效的vip券
     *
     * @param payAmount
     * @return
     */
    CouponInfo selectCouponByPayAmount(@Param("payAmount") Integer payAmount);

    CouponInfo selectNewCoupon(@Param("type") Integer type, @Param("price") Integer price);

    CouponInfo selectShareCouponByTypePrice(@Param("typeShare") Integer typeShare, @Param("price") Integer price);

    int deleteByPrimaryKey(Integer id);

    CouponInfo selectByPrimaryKey(Integer id);

    List<CouponInfo> selectAll();

    int updateByPrimaryKey(CouponInfo record);

    CouponInfo selectRecommendCoupon(@Param("type") Integer type);

    List<CouponInfo> selectByType(@Param("type") Integer type);

    List<CouponInfo> getCouponByType(@Param("type") Integer type);

}
